package org.roguelikedevelopment.dweller.j2me;

import java.io.DataInputStream;
import javax.microedition.midlet.MIDlet;

import org.roguelikedevelopment.dweller.common.application.DataStorage;
import org.roguelikedevelopment.dweller.common.application.DwellerApplication;
import org.roguelikedevelopment.dweller.common.application.DwellerCanvas;
import org.roguelikedevelopment.dweller.common.game.GameSettings;
import org.roguelikedevelopment.dweller.common.game.worldfactory.EntityDataHandler;
import org.roguelikedevelopment.dweller.common.game.worldfactory.WorldFactory;
import org.roguelikedevelopment.dweller.common.util.Rng;
import org.roguelikedevelopment.dweller.common.util.logger.Logger;

public class TestMidlet extends MIDlet implements DwellerApplication {
	private RecordStoreStorage rs;
	
	public TestMidlet() {
	}
	
	public DataInputStream getFile(String name) {
		return new DataInputStream(getClass().getResourceAsStream(name));
	}
	
	protected void startApp() {
		Logger.debug("TestMidlet.startApp()");
		rs = new RecordStoreStorage();
		EntityDataHandler.load(getFile("/monsters.bin"), getFile("/items.bin"), getFile("/players.bin"));
		Rng.setSeed(System.currentTimeMillis());
		WorldFactory.initialize(this);
		
	}
	
	public void setDefaultKeys() {
	}
	
	protected void pauseApp() {
	}
	
	public void destroyApp(boolean unconditional) {
		notifyDestroyed();
	}
	
	public void exit() {
		destroyApp(true);
	}


	public DataStorage getDataStorage() {
		return rs;
	}

	public String getKeyCodeName(int keyCode) {
		return "";
	}

	public DwellerCanvas getCanvas() {
		return null;
	}

	public void settingsChanged(GameSettings settings) {
	}

}
